package cn.demomaster.quickpicturer.config;

import android.app.Activity;

import androidx.fragment.app.Fragment;

import java.io.File;

import cn.demomaster.quickpicturer.constants.ImageSourceType;

public class ImageConfigBuilder {
    public String authority;
    ImageSourceType[] sources;
    String[] sourceNames;
    int maxImages;
    boolean multipleSelection;
    int cropWidth;
    int cropHeight;
    File saveDirectory;
    Activity activity;
    Fragment fragment;
    public ImageConfigBuilder(Activity activity) {
        this.activity = activity;
        this.authority = activity.getPackageName() + ".fileprovider";
    }
    public ImageConfigBuilder(Fragment fragment) {
        this.fragment = fragment;
        this.authority = fragment.getActivity().getPackageName() + ".fileprovider";
    }
//    public ImageConfigBuilder(Activity activity, ImageSourceType[] imageSourceTypes) {
//        this.activity = activity;
//        this.sources = imageSourceTypes;
//    }
//
//    public ImageConfigBuilder(Fragment fragment, ImageSourceType[] imageSourceTypes) {
//        this.fragment = fragment;
//        this.sources = imageSourceTypes;
//    }

    public ImageConfigBuilder setCropWidth(int cropWidth) {
        this.cropWidth = cropWidth;
        return this;
    }

    public ImageConfigBuilder setCropHeight(int cropHeight) {
        this.cropHeight = cropHeight;
        return this;
    }

    public ImageConfigBuilder setSaveDirectory(File saveDirectory) {
        this.saveDirectory = saveDirectory;
        return this;
    }

    public ImageConfigBuilder setSources(ImageSourceType... sources) {
        this.sources = sources;
        return this;
    }

    public ImageConfigBuilder setMaxImages(int maxImages) {
        this.maxImages = maxImages;
        return this;
    }

    public ImageConfigBuilder setMultipleSelection(boolean multipleSelection) {
        this.multipleSelection = multipleSelection;
        return this;
    }

    public ImageConfig build() {
        return new ImageConfig(this);
    }

    public ImageSourceType[] getSources() {
        return sources;
    }

    public int getCropHeight() {
        return cropHeight;
    }

    public int getCropWidth() {
        return cropWidth;
    }

    public int getMaxImages() {
        return maxImages;
    }

    public String[] getSourceNames() {
        return sourceNames;
    }

    public ImageConfigBuilder setSourceNames(String[] sourceNames) {
        this.sourceNames = sourceNames;
        return this;
    }

    public ImageConfigBuilder setAuthority(String authority) {
        this.authority = authority;
        return this;
    }
}
